package net.gcode.sdkscheduleparser.gui.tree;

import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

public class CheckBoxNodeTreeSample {
	public static void main(String args[]) {
		JFrame frame = new JFrame("CheckBox Tree");
		DefaultMutableTreeNode root = new DefaultMutableTreeNode("Stundenplan");
		root.add(new DefaultMutableTreeNode("modul1"));

		JTree test = new JTree(root);
		CheckTreeManager checkTreeManager = new CheckTreeManager(test);
		frame.add(test);
		// to get the paths that were checked
		TreePath checkedPaths[] = checkTreeManager.getSelectionModel().getSelectionPaths();
		frame.setSize(300, 150);
		frame.setVisible(true);
		root.removeAllChildren();
		root.add(new DefaultMutableTreeNode("modul2"));
		root.add(new DefaultMutableTreeNode("modul3"));
		test.updateUI();
		test.repaint();

	}
}

class NamedVector extends Vector {
	String name;

	public NamedVector(String name) {
		this.name = name;
	}

	public NamedVector(String name, Object elements[]) {
		this.name = name;
		for (int i = 0, n = elements.length; i < n; i++) {
			add(elements[i]);
		}
	}

	@Override
	public String toString() {
		return "[" + name + "]";
	}
}
